package com.pft.web.util;

import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

public class DisplayUtil
{
  public static float dpToPx(float paramFloat)
  {
    return (int)(getDensity() * paramFloat + 0.5F);
  }
  
  public static float getActivityBrightness(Activity paramActivity)
  {
    return paramActivity.getWindow().getAttributes().screenBrightness;
  }
  
  public static float getDensity()
  {
    return getDisplayMetrics().density;
  }
  
  public static DisplayMetrics getDisplayMetrics()
  {
    return Utils.getContext().getResources().getDisplayMetrics();
  }
  
  public static int getHeight()
  {
    return getDisplayMetrics().heightPixels;
  }
  
  public static float getScaledDensity()
  {
    return getDisplayMetrics().scaledDensity;
  }
  
  public static int getWidth()
  {
    return getDisplayMetrics().widthPixels;
  }
  
  public static boolean isLandscape()
  {
    return Utils.getContext().getResources().getConfiguration().orientation == 2;
  }
  
  public static boolean isPortrait()
  {
    return Utils.getContext().getResources().getConfiguration().orientation == 1;
  }
  
  public static int pxToDp(float paramFloat)
  {
    return (int)(paramFloat / getDensity() + 0.5F);
  }
  
  public static int pxToSp(float paramFloat)
  {
    return (int)(paramFloat / getScaledDensity() + 0.5F);
  }
  
  public static void setActivityBrightness(float paramFloat, Activity paramActivity)
  {
    Window window = paramActivity.getWindow();
    WindowManager.LayoutParams localLayoutParams = window.getAttributes();
    localLayoutParams.screenBrightness = paramFloat;
    window.setAttributes(localLayoutParams);
  }
  
  public static int spToPx(float paramFloat)
  {
    return (int)(getScaledDensity() * paramFloat + 0.5F);
  }
}
